package com.custom.customswitchbutton;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private CustomSwitchButton mCsb1;
    private CustomSwitchButton mCsb2;
    private TextView mTev1;
    private TextView mTev2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mCsb1 = findViewById(R.id.csb_main_c1);
        mCsb2 = findViewById(R.id.csb_main_c2);
        mTev1 = findViewById(R.id.tev_main_t1);
        mTev2 = findViewById(R.id.tev_main_t2);
        mCsb1.setOnChangeBsvListener(new CustomSwitchButton.OnChangeBsvListener() {
            @Override
            public void onChangeBsv(boolean isState) {
                if (isState) {
                    mTev1.setText("关闭自动更新");
                } else {
                    mTev1.setText("开启自动更新");
                }
            }
        });
        mCsb2.setOnChangeBsvListener(new CustomSwitchButton.OnChangeBsvListener() {
            @Override
            public void onChangeBsv(boolean isState) {
                if (isState) {
                    mTev2.setText("关闭通知");
                } else {
                    mTev2.setText("开启通知");
                }
            }
        });
    }
}
